using UnityEngine;
using System.Collections;

public class EnemyShooting : MonoBehaviour 
{
	public GameObject projectile = null;
	public float timeBetweenShotsMin = 0.5f;
	public float timeBetweenShotsMax = 1.0f;
	
	private float _nextShot = 0f;
	private Transform _transform;
	
	void Start()
	{
		_transform = transform;
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(Time.time > _nextShot)
		{
			//Assign new next shot
			_nextShot = Time.time + Random.Range(timeBetweenShotsMin, timeBetweenShotsMax);
			
			//Fire the projectile
			Instantiate(projectile, _transform.position, _transform.rotation);
		}
	}
}
